package com.zust.data.entity.base;

import com.fasterxml.jackson.annotation.JsonIgnore;
import org.springframework.data.annotation.*;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import org.springframework.data.mongodb.core.mapping.Field;

import javax.persistence.EntityListeners;
import java.time.LocalDateTime;

/**
 * @author senselyan
 * @date 2018/4/19 17:05
 *
 */
@EntityListeners(AuditingEntityListener.class)
public class BaseEntity {

    @Id
    private String id;

    public static final int NOT_DELETED_FLAG = 0;
    public static final int DELETED_FLAG = 1;
    @Field
    @JsonIgnore
    private int deletedFlag = 0;

    @Field
    @CreatedDate
    private LocalDateTime createTime;
    @Field
    @LastModifiedDate
    private LocalDateTime updateTime;

    @CreatedBy
    private String createBy;

    @LastModifiedBy
    private String updateBy;

    public BaseEntity() {
    }

    public int getDeletedFlag() {
        return this.deletedFlag;
    }

    public void setDeletedFlag(int deletedFlag) {
        this.deletedFlag = deletedFlag;
    }

    public LocalDateTime getCreateTime() {
        return createTime;
    }

    public void setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
    }

    public LocalDateTime getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(LocalDateTime updateTime) {
        this.updateTime = updateTime;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }


    public String getCreateBy() {
        return createBy;
    }

    public void setCreateBy(String createBy) {
        this.createBy = createBy;
    }

    public String getUpdateBy() {
        return updateBy;
    }

    public void setUpdateBy(String updateBy) {
        this.updateBy = updateBy;
    }
}
